package br.com.emanuelvictor.architectureandroid.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import br.com.emanuelvictor.architectureandroid.R;
import br.com.emanuelvictor.architectureandroid.app1.util.PointVariables;
import br.com.emanuelvictor.architectureandroid.util.Interface;
import br.com.emanuelvictor.architectureandroid.util.Navigation;

public class Login extends Fragment implements Interface{
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		try {
			this.configureActionBar();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return inflater.inflate(R.layout.main_menu, null);
	}

	@Override
	public void goTo(Object obj) throws Exception {
		((Interface)getActivity()).goTo(obj);
	}

	@Override
	public void update() throws Exception {
		
	}

	@Override
	public void handle(Object obj) throws Exception {
		if (((View)obj).getId()==R.id.coffe) {
			Toast.makeText(getActivity(), "Entra no fragmento do café", Toast.LENGTH_LONG).show();
		}else{
			((Navigation)getActivity()).setVariables(new PointVariables(getActivity()));
			this.goTo(((Navigation)getActivity()).getVariables().getFragment());
			((Navigation) getActivity()).getSupportActionBar().setIcon(R.drawable.ic_launcher);
		}
		
	}

	@Override
	public void back() throws Exception {
		this.getActivity().finish();
	}

	@Override
	public void home() throws Exception {
	}

	@Override
	public void configureActionBar() throws Exception {
		((Navigation) getActivity()).getSupportActionBar().setTitle("Itai android");
		((Navigation) getActivity()).getSupportActionBar().setIcon(R.drawable.logo_itai);
	}
}
